package br.com.wagnerpaz.javahook;

import java.awt.event.KeyEvent;
import java.text.MessageFormat;


public class Test
{
	public static void main(String[] args)
	{
		HookManager.installKeyboardHook(new NativeKeyboardListener()
		{
			@Override
			public boolean keyPressed(NativeKeyboardEvent e)
			{
				System.out.println("Press: " + KeyEvent.getKeyText(e.getKeyCode()) );
				
				if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
				{
					HookManager.uninstallKeyboardHook();
				}
				
				return false;
			}
			
			@Override
			public boolean keyReleased(NativeKeyboardEvent e)
			{
				System.out.println("Release: " + KeyEvent.getKeyText(e.getKeyCode()) );
				return false;
			}
		});
		
		HookManager.installMouseHook(new NativeMouseListener()
		{
			@Override
			public boolean mousePressed(NativeMouseEvent e)
			{
				System.out.println(MessageFormat.format("P[{0}, {1}]", e.getX(), e.getY()));
				return true;
			}
			
			@Override
			public boolean mouseReleased(NativeMouseEvent e)
			{
				System.out.println(MessageFormat.format("R[{0}, {1}]", e.getX(), e.getY()));
				return true;
			}
			
			@Override
			public boolean mouseMoved(NativeMouseEvent e)
			{
				System.out.println(MessageFormat.format("M[{0}, {1}]", e.getX(), e.getY()));
				return true;
			}

			@Override
			public boolean mouseWheelMoved(NativeMouseWheelEvent e)
			{
				System.out.println(MessageFormat.format("W[{0}, {1}]", e.getX(), e.getY()));
				return true;
			}
		});
	}
}

